package com.atguigu.gulimall.order.web;

import com.alibaba.fastjson.JSON;
import com.atguigu.common.utils.PageUtils;
import com.atguigu.common.utils.R;
import com.atguigu.gulimall.order.enume.OrderStatusEnum;
import com.atguigu.gulimall.order.feign.WmsFeignService;
import com.atguigu.gulimall.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

@Controller
public class ListWebController {

    @Autowired
    private OrderService orderService;

    /**
     * 订单详情页
     * @param params
     * @param model
     * @return
     */
    @RequestMapping("/list")
    public String list(@RequestParam Map<String, Object> params, Model model){
        Object out_trade_no = params.get("out_trade_no");
        if (out_trade_no!=null){
            /*
            支付成功
            1.修改订单状态oms_order
            2.减库存，减库存锁定量 wms_ware_sku
            3.删除购物车信息
             */
            String orderSn=out_trade_no.toString();
            System.out.println(orderSn);
            orderService.paySuccess(orderSn);
        }

        PageUtils page = orderService.queryPageWithItem(params);

        model.addAttribute("orders",page);
        return "list";
    }

}
